import 'dart:convert';

import 'package:emby/model/session_info.dart';
import 'package:emby/model/user.dart';

class LoginInfo {
  LoginInfo({
    this.user,
    this.sessionInfo,
    this.accessToken,
    this.serverId,
  });

  User user;
  SessionInfo sessionInfo;
  String accessToken;
  String serverId;

  factory LoginInfo.fromRawJson(String str) => LoginInfo.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory LoginInfo.fromJson(Map<String, dynamic> json) => LoginInfo(
        user: User.fromJson(json["User"]),
        sessionInfo: SessionInfo.fromJson(json["SessionInfo"]),
        accessToken: json["AccessToken"],
        serverId: json["ServerId"],
      );

  Map<String, dynamic> toJson() => {
        "User": user.toJson(),
        "SessionInfo": sessionInfo.toJson(),
        "AccessToken": accessToken,
        "ServerId": serverId,
      };
}
